<?php
/*
 * 手机客户端店铺-商品数量确认接口
 * 2014-03-10
 * 2014-05-08 (已查) 
 */
include "inc/public_header.php";

include "func/user.php";				//用户信息处理函数


$reJson = array(); //构建返回值

$json 		= $_REQUEST["json"];		

//获取用户信息
$uInfoArr = user_getInfoFromUUID();
if(!$uInfoArr){
	echo json_encode(array("success"=>"0","errCode"=>"0","msg"=>"没有获取到用户信息"));
	die;
}
$uid = $uInfoArr["uid"];//用户信息主键

//$uid = "10638";


$arr=json_decode($json,true);
$list=array();
$list1=array();
 
foreach($arr as $val){
    $sql = "select b.product_name,b.quantity,b.salesvolume,a.product_id,b.shangjia from (SELECT product_id from shop_product_gwc where uid='".$uid."') a right join  shop_product  b on a.product_id=b.product_id where b.product_id = '".$val['goodsId']."'";
	$db1->query($sql);
	$db1->next_record();
	if (!$db1->f("product_id")){
		$list[]=$db1->f("product_name");
	}
	if (($db1->f("quantity"))-($db1->f("salesvolume"))<$val['goodsNum']){
		$list1[]=$db1->f("product_name");
	}
	if ($db1->f("shangjia")=="0"){
		$list2[]=$db1->f("product_name");
	}
}
if ($list){
	echo json_encode(array("success"=>"0","errCode"=>"1","msg"=>"该商品已经不在购物车","list"=>$list));
	die;
}else if ($list2){
	echo json_encode(array("success"=>"0","errCode"=>"3","msg"=>"商品已下架","list"=>$list2));
	die;
}else if ($list1){
	echo json_encode(array("success"=>"0","errCode"=>"2","msg"=>"商品库存不足","list"=>$list1));
	die;
}else{
	echo json_encode(array("success"=>"1"));
	die;
}
?>
